package com.bbex.mapper;

import com.bbex.entity.Coin;
import com.bbex.sql.build.CoinSqlBuild;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

@Mapper
public interface CoinDao {


    @SelectProvider(type = CoinSqlBuild.class, method = "findById")
    Coin findById(String id);

    @Select("select id,name,full_name as fullName,domain,whitepaper_url as whitepaperUrl,token_volume as tokenVolume,ico_price as icoPrice," +
            "circulate_volume as circulateVolume,token_status as tokenStatus,status,ex_min_volume as exMinVolume,withdraw_min_volume as withdrawMinVolume," +
            "withdraw_max_volume as withdrawMaxVolume,withdraw_day_max_volume as withdrawDayMaxVolume,withdraw_fee as withdrawFee,withdraw_fee_type as withdrawFeeType," +
            "coin_type as coinType,parent_id as parentId,icon_id as iconId,remarks from js_plat_coin where id =#{id}")
    Coin findByCoinid(String id);

    @Select("select " + CoinSqlBuild.columns + " from js_plat_coin where name =#{name} limit 1")
    Coin findByName(String name);

    @Select("select id,name,full_name as fullName,domain,whitepaper_url as whitepaperUrl,token_volume as tokenVolume,ico_price as icoPrice," +
            "circulate_volume as circulateVolume,token_status as tokenStatus,status,ex_min_volume as exMinVolume,withdraw_min_volume as withdrawMinVolume," +
            "withdraw_max_volume as withdrawMaxVolume,withdraw_day_max_volume as withdrawDayMaxVolume,withdraw_fee as withdrawFee,withdraw_fee_type as withdrawFeeType," +
            "coin_type as coinType,parent_id as parentId,icon_id as iconId,remarks from js_plat_coin")
    List<Coin> findAll();

    @Select("select " + CoinSqlBuild.columns + " from js_plat_coin where parent_id = #{parentId}")
    List<Coin> findByParentId(String parentId);

    @Select("select " + CoinSqlBuild.columns + " from js_plat_coin where coin_type = #{coinType}")
    List<Coin> findByCoinType(String coinType);
}
